﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using ExamDemo.Models;

namespace ExamDemo.Data
{
    public class ExamDemoInsert:DropCreateDatabaseAlways<ExamDemoDb>
    {
        protected override void Seed(ExamDemoDb db)
        {
            db.Users.Add(new Models.Users
            {
                Username="zhu",
                Password="123",
                CreatedAt=DateTime.Now,
                UpdatedAt=DateTime.Now,
                Version=0
            });
            db.Users.Add(new Models.Users
            {
                Username = "de",
                Password = "123",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });
            db.Users.Add(new Models.Users
            {
                Username = "ming",
                Password = "123",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });
            db.Messages.AddRange(new List<Messages>
            {
                new Messages
                {
                FormUserId = 1,
                Content = "你好帅",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
                }

            });
            db.Messages.AddRange(new List<Messages>
            {
                new Messages
                {
                FormUserId = 1,
                Content = "你好棒",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
                }

            });

            db.Comments.AddRange(new List<Comments>
            {
                new Comments
                {
                    MsgId=1,
                    FromUserId=1,
                    Content="同意",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
                }
            });
            db.Comments.AddRange(new List<Comments>
            {
                new Comments
                {
                    MsgId=1,
                    FromUserId=1,
                    Content="不同意",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
                }
            });

            db.SaveChanges();
            base.Seed(db);
        }
    }
}